<?php

namespace App\Http\Repositories\EdgeManage;

use App\Http\Repositories\Repository;
use App\Models\CostSetting;

/**
 * cost_setting
 */
class CostSettingRepo extends Repository
{
    const MODEL = CostSetting::class;

    public function search(array $params)
    {
        $conditions = [];

        if (!empty($params['type'])) {
            array_push($conditions, ['type', 'where', $params['type']]);
        }

        if (!empty($params['status'])) {
            array_push($conditions, ['status', 'where', $params['status']]);
        }

        if (!empty($params['begin_time'])) {
            array_push($conditions, ['created_at', 'where', ['>=', $params['begin_time']]]);
        }

        if (!empty($params['end_time'])) {
            array_push($conditions, ['created_at', ' where', ['<=', $params['end_time']]]);
        }

        return $this->formatSearch($conditions);
    }
}
